package com.aceitunaproject.server.equipment;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.aceitunaproject.server.combat.CombatEffects;
import com.aceitunaproject.server.specialability.SpecialAbility;
import com.aceitunaproject.server.terrain.MovementEffects;
import com.aceitunaproject.server.terrain.TerrainEquipmentCombo;
import com.aceitunaproject.server.terrain.TerrainType;

/**
 * @author Federico Bergstein
 * 
 *         Utility methods for testing equipment related classes
 */

public class TestUtil {

	/**
	 * 
	 * Generates a simple instance of the Equipment Class, containing only one
	 * instance of each combat/movement effects on its inner effects collections
	 * 
	 * @param name
	 *            the name of the equipment
	 * @param combatEffects
	 *            the combat effects in the given terrain
	 * @param movementEffects
	 *            the movement effects in the given terrain
	 * @param combo
	 *            the combination of terrain and equipment to which will be
	 *            applied the comboEffect paramenter
	 * @param comboEffect
	 *            the combatEffect for the combination parameter of
	 *            terrain/equipment
	 * @param father
	 *            the equipment's superclass
	 * @param terrainType
	 *            the type of terrain to relate with the combatEffects and
	 *            movementEffects parameters
	 * @return
	 */
	public static Equipment generateSimpleTestEquipment(String name,
			CombatEffects combatEffects, MovementEffects movementEffects,
			TerrainEquipmentCombo combo, CombatEffects comboEffect,
			Equipment father, TerrainType terrainType) {

		Map<TerrainType, CombatEffects> terrainCombatEffects = new HashMap<TerrainType, CombatEffects>();
		Map<TerrainType, MovementEffects> terrainMovementEffects = new HashMap<TerrainType, MovementEffects>();
		Map<TerrainEquipmentCombo, CombatEffects> terrainEquipmentCombinationCombatEffects = new HashMap<TerrainEquipmentCombo, CombatEffects>();
		Map<Equipment, CombatEffects> equipmentCombatEffects = new HashMap<Equipment, CombatEffects>();

		terrainCombatEffects.put(terrainType, combatEffects);
		terrainMovementEffects.put(terrainType, movementEffects);

		if (combo != null)
			terrainEquipmentCombinationCombatEffects.put(combo, comboEffect);

		return new Equipment(new CombatEffects(0, 0, 0, 0), name,
				terrainCombatEffects, terrainMovementEffects,
				terrainEquipmentCombinationCombatEffects,
				equipmentCombatEffects, father);

	}

	/**
	 * 
	 * Generates a simple instance of the Equipment Class, containing only one
	 * instance of a combat effect on its inner effects collection, related to a
	 * single enemy equipment
	 * 
	 * @param name
	 *            the name of the equipment
	 * @param combatEffects
	 *            the combat effects for the given enemy equipment
	 * @param enemyEquipment
	 *            the enemy equipment
	 * @param father
	 *            the equipment's superclass
	 * @return
	 */
	public static Equipment generateSimpleTestEquipment(String name,
			CombatEffects combatEffects, Equipment enemyEquipment,
			Equipment father) {

		Map<Equipment, CombatEffects> equipmentCombatEffects = new HashMap<Equipment, CombatEffects>();
		equipmentCombatEffects.put(enemyEquipment, combatEffects);
		return new Equipment(new CombatEffects(0, 0, 0, 0), name, null, null,
				null, equipmentCombatEffects, father);

	}

	/**
	 * 
	 * Generates a simple instance of the Equipment Class, containing only one
	 * instance a combat effect on its inner effects collection, related to a
	 * single enemy equipment
	 * 
	 * @param name
	 *            the name of the equipment
	 * @param combatEffects
	 *            the combat effects for the given enemy equipment
	 * @param enemyEquipment
	 *            the enemy equipment
	 * @param father
	 *            the equipment's superclass
	 * @param specialAbilities
	 *            a list of special abilities for this equipment
	 * @return
	 */
	public static Equipment generateSimpleTestEquipment(String name,
			CombatEffects combatEffects, Equipment enemyEquipment,
			Equipment father, List<SpecialAbility> specialAbilities) {

		Map<Equipment, CombatEffects> equipmentCombatEffects = new HashMap<Equipment, CombatEffects>();
		equipmentCombatEffects.put(enemyEquipment, combatEffects);
		return new Equipment(new CombatEffects(0, 0, 0, 0), name, null, null,
				null, equipmentCombatEffects, father, specialAbilities);

	}

}
